package demo5;

import java.util.*;

//牛客网:集合

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] hash = new int[100001];
        List<Integer> list = new ArrayList<>();
        for(int i = 0; i<n+m; i++) {
            int x = in.nextInt();
            if(hash[x] == 0) {
                hash[x] = 1;
                list.add(x);
            }
        }
        Collections.sort(list);
        for(int i = 0; i<list.size(); i++) {
            System.out.print(list.get(i) + " " );
        }
    }
}